package com.huangpeng.designmodel.singleton;

/**
 * @Author hp
 * @Title 静态内部类-强烈推荐
 * @Package
 * @Date 2022/1/19 10:18
 * @Description
 * @Version 1.0
 */
public class StaticInnerClass {
    //私有构造函数
    public StaticInnerClass() {
    }
    //私有的静态内部类
    private static class clazz{
        private static StaticInnerClass staticInnerClass = new StaticInnerClass();
    }
    //对外的公有方法
    public static StaticInnerClass getInstance(){
        return clazz.staticInnerClass;
    }
    public static void main(String[] args){
        StaticInnerClass a1 = StaticInnerClass.getInstance();
        System.out.println("*********** " + a1.hashCode());
        StaticInnerClass a2 = StaticInnerClass.getInstance();
        System.out.println("*********** " + a2.hashCode());
    }
}
